﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeWork.Library.DataStructure;

namespace BDHomePage.BLL
{
    public class LinkGroup
    {
        private ReadWriteCustomCollection<Link> _links;
        public ReadOnlyCustomCollection<Link> Links
        {
            get { return this._links.ReadOnlyClone(); }
        }

        private string _groupTitle;
        public string GroupTitle
        {
            get { return this._groupTitle; }
            set { this._groupTitle = value; }
        }

        private string _groupDescription;
        public string GroupDescription
        {
            get { return this._groupDescription; }
            set { this._groupDescription = value; }
        }

        private int _sortOrder;
        public int SortOrder
        {
            get { return this._sortOrder; }
            set { this._sortOrder = value; }
        }

        public LinkGroup()
        {
            _links = new ReadWriteCustomCollection<Link>();
        }

        public void AddLinkGroup()
        {
            // DB code to create new group
        }

        public void RemoveLinkGroup()
        {
            // DB code to delete existing group
        }

        public void UpdateLinkGroup()
        {
            // DB code to updaate existing group
        }

        public void RemoveLink(Link linkToRemove)
        {
            if (this._links.Remove(linkToRemove))
            {
                // DB code to delete link from group
            }
        }

        public void AddLinkToGroup(Link linkToAdd)
        {
            this._links.Add(linkToAdd);
            // DB code to save group in db
        }
    }
}
